package com.lanhao.aot.image;

import java.io.File;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;

import com.google.common.base.Splitter;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.UUID;

public class ImageUtil {
	public static File file = new File("D:/t_survey_conclusion_202102082229.txt");
	public static Splitter splitter = Splitter.on("\\|");
	public static void main(String[] args) throws Exception {
		String readString = FileUtil.readString(file,Charset.forName("UTF-8"));
		List<String> splitToList = splitter.splitToList(readString);
		for (int i = 0; i < splitToList.size(); i++) {
			String imageUrls = splitToList.get(i);
			String[] split = imageUrls.split(",");
			for (String url : split) {
				URL imageUrl = new URL(url);
				System.out.println("处理url=" + url);
				FileUtil.writeFromStream(imageUrl.openStream(), new File("D:/勘察结论图片/" + UUID.fastUUID().toString() + ".jpg"));
			}
		}
		
	}
}
